<?php

/**

 * Created by PhpStorm.

 * User: Administrator

 * Date: 2018/3/29 0029

 * Time: 16:03

 */



namespace app\home\controller;

use think\Db;



class Kepds extends Base

{

        public function index(){
             $this->publicIndex();
             
             
              $id = intval(input('param.id'));
        if($id){
             //每日更新
        $where['is_del']=0;
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=$id;
        $data_fg = Db::name('works')->where($where)->order('sort desc,id desc')->select();
        $this->assign('data_fg',$data_fg);
        $this->assign('data_seo',getColumnseo(2));
        
        
        //100%客片
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=37;
        $data_kp = Db::name('works')->where($where)->order('sort desc,id desc')->select();
        $this->assign('data_kp',$data_kp);

  
//        $page = $data_kp->render();
//        $this->assign('page', $page);
        
        }else{
                 //每日更新
        $where['is_del']=0;
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=36;
        $data_fg = Db::name('works')->where($where)->order('sort desc,id desc')->select();
        $this->assign('data_fg',$data_fg);
        $this->assign('data_seo',getColumnseo(2));
        
        
        //100%客片
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=37;
        $data_kp = Db::name('works')->where($where)->order('sort desc,id desc')->paginate(2,false,['query' => request()->param()]);
        $this->assign('data_kp',$data_kp);

  
        $page = $data_kp->render();
        $this->assign('page', $page);
            
        }
        
 
        
        
       
            return $this->fetch();    
        }
        
        public function mrkp(){
             $this->publicIndex();
             
             
              $id = intval(input('param.id'));
        if($id){
             //每日更新
        $where['is_del']=0;
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=$id;
        $data_kp = Db::name('works')->where($where)->order('sort desc,id desc')->select();
        $this->assign('data_kp',$data_kp);
        $this->assign('data_seo',getColumnseo(2));
        
        
        }else{
                 //每日更新
        $where['is_del']=0;
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=36;
        $data_fg = Db::name('works')->where($where)->order('sort desc,id desc')->select();
        $this->assign('data_fg',$data_fg);
        $this->assign('data_seo',getColumnseo(2));
        
        
        //100%客片
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=37;
        $data_kp = Db::name('works')->where($where)->order('sort desc,id desc')->paginate(2,false,['query' => request()->param()]);
        $this->assign('data_kp',$data_kp);

  
        $page = $data_kp->render();
        $this->assign('page', $page);
            
        }
        
 
        
        
       
            return $this->fetch();    
        }

        
        public function mzkp() {
               $this->publicIndex();
             //每周客赏
        $where['is_del']=0;
        $where['is_del']=0;
        $where['is_recom']=1;
        $where['sign']="pc";
         $where['class_id']=36;
        $data_mzkp = Db::name('works')->where($where)->order('sort desc,id desc')->paginate(4,false,['query' => request()->param()]);
        
        $page = $data_mzkp->render();
        $this->assign('page',$page);
        $this->assign('data_mzkp',$data_mzkp);
        return $this->fetch();
        }
        
        
        
        
        
            //客片详情页

        public function details($id=0,$nid=0,$pid=0){
         $this->publicIndex();


        if(!empty($id)){
            
            
            

            $where['id']=$id;

            $where = [

                'a.sign'=>"pc",

                'a.is_del'=>0,

                'a.is_show'=>1,

                'a.id'=>$id

            ];

            $data_kp = Db::name('works')->alias('a')

                ->where($where)

                ->order('a.sort desc,a.id desc')

                ->find();
            
             Db::name('works')->alias('a')->where('id',$id)->update(['click'=>$data_kp['click']+1]);
             
             
             
                   //查询出推荐
                $where_s["class_id"] =$data_kp['class_id'];
                
                
                    $data_style_s = Db::name('works')->alias('a')
                    ->where($where_s)
                    ->order('a.sort desc,a.id desc')->limit(4)
                    ->select();
                 
                $this->assign('data_style_s',$data_style_s);

         
            $this->assign('data_kp',$data_kp);

        }else{

            return json(['code'=>0,'msg'=>'非法请求']);

        }

        //底部详情也广告

        $data_bannerfont = Db::name('banner')->where('is_del=0 and is_show=1 and sign="pc" and class_id=41')

            ->order('sort desc,id desc')->field('banner_img,out_link')->find();

        $this->assign('data_bannerfont',$data_bannerfont);

        //推荐客片

        $where = [

            'a.sign'=>"pc",

            'a.is_show'=>1,

            'a.is_del'=>0

        ];

        $data_kplist = Db::name('works')->alias('a')

            ->where($where)

            ->order('a.sort asc')

            ->paginate(12);

        $this->assign('data_kplist',$data_kplist);

        return $this->fetch();

    }
        
        public function fgyp_nr() {
             $id = intval(input('param.id'));
             if($id){
                 $where['id'] = $id;
                  $data_fgyp = Db::name('zp')->where($where)->select();

                  $arr = array();
                  foreach($data_fgyp as $k=>$v){
                     $arr = $data_fgyp[$k]['works_photo'];
                  }
                $new_arr = explode(',',$arr);
                $ret_data_fgyp = array();
                 foreach($new_arr as $v ){
                     $where_fgyp_new['pic_id'] = $v;
                     //$wheres['pic_id'] =array('in','695');
                     $new_data_fgyp = Db::name('works_pic')->where($where_fgyp_new)->select();
                    $ret_data_fgyp = array_merge($ret_data_fgyp,$new_data_fgyp);
                 }
            
                     $this->assign('ret_data_fgyp',$ret_data_fgyp);
                 return $this->fetch();
             }
             else{
              return $this->error('系统问题，请联系网络管理员');
             }
            
        }

    public function khfk() {
        return $this->fetch();
    }



}